function kte = computeKte(i,elements,model)
e = model.getElement(i-1);
f = e.getFace();
B = zeros(3,8);
C = elements(i).constitutiveMatrix;
kte = zeros(8,8);
ng = e.getNumGaussPoint();
t = elements(i).thickness;

for j=1:ng
    xi = e.getGaussPoint(j-1);
    w = e.getGaussWeight(j-1);
    jac = f.jacXAt(xi);
    detJac = det(jac);
    B = e.computeB(f,B,xi);
    kte = kte + B'*C*B*(w*detJac*t);
end
if elements(i).isCrack == 1
    kte = kte - elements(i).Kdxi*...
        (elements(i).Kxixi\elements(i).Kxid);
end
